<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('选择库位(储位)')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>库位编码：</label>
                            <input type="text" name="storageCode"/>
                        </li>
                        <li>
                            <label>库位名称：</label>
                            <input type="text" name="storageName"/>
                        </li>
                        <li>
                            <label>库位条码：</label>
                            <input type="text" name="storageBarcode"/>
                        </li>
                        <li>
                            <label>所属库区：</label>
                            <select name="reservoirId" id="reservoirId">
                                <option value="">所有</option>
                                <!--<option value="-1">代码生成请选择字典属性</option>-->
                            </select>
                        </li>
                        <li>
                            <label style="width: 80px;">是否空库位：</label>
                            <select name="isEmpty" th:with="type=${@dict.getType('sys_yes_no')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>


        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var storageTypeDatas = [[${@dict.getType('wms_storage_type')}]];
    var storageAttributeDatas = [[${@dict.getType('wms_storage_attribute')}]];
    var isEmptyDatas = [[${@dict.getType('sys_yes_no')}]];
    var prefix = ctx + "wh/storage";

    $(function() {
        var options = {
            url: prefix + "/selectList",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            modalName: "库位(储位)设置",
            columns: [{
                    radio: true
                },
                {
                    field: 'id',
                    title: '库位(储位)设置id',
                    visible: false
                },
                {
                    field: 'storageCode',
                    title: '库位编码'
                },
                {
                    field: 'storageName',
                    title: '库位名称'
                },
                {
                    field: 'storageBarcode',
                    title: '库位条码'
                },
                {
                    field: 'reservoirName',
                    title: '所属库区'
                },
                {
                    field: 'storageType',
                    title: '库位类型',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(storageTypeDatas, value);
                    }
                },
                {
                    field: 'storageAttribute',
                    title: '库位属性',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(storageAttributeDatas, value);
                    }
                },
                {
                    field: 'storageSizeName',
                    title: '库位尺寸'
                },
                {
                    field: 'outbound',
                    title: '出库口'
                },
                {
                    field: 'isEmpty',
                    title: '空库位标识',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(isEmptyDatas, value);
                    }
                }]
        };
        $.table.init(options);

        //初始化库区设置
        getReservoirList();
    });

    /**
     * 获取库区设置下拉框信息
     */
    var warehousePrefix = ctx + "wh/reservoir"
    function getReservoirList(){
        var data = {};
        var config = {
            url: warehousePrefix + "/ajaxList",
            type: "post",
            dataType: "json",
            data: data,
            beforeSend: function () {
                $.modal.loading("正在处理中，请稍后...");
            },
            success: function(result) {
                //console.log(result)
                if (result.code == web_status.SUCCESS) {
                    var str="";
                    $.each( result.data,function(index,value){
                        str+='<option value="'+value.id+'">'+value.reservoirCode+'---'+value.reservoirName+'【'+value.warehouseName+'】'+'</option>';
                    });
                    $('#reservoirId').append(str);
                }else {
                    $.modal.alertError(result.msg);
                }
                $.modal.closeLoading();
            }
        };
        $.ajax(config)
    }


</script>
</body>
</html>